package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.BankException;
import com.acme.bankapp.domain.bank.NotEnoughFundsException;
import com.acme.bankapp.domain.bank.OverDraftLimitExceededException;

public class BankApplication 
{
	
	public static void main(String[] args) 
	{
		Bank bank = new Bank();
		BankService.generateClients(bank, 7);
		BankService.printMaximumAmountToWithdraw(bank);
		try {
			BankService.modifyBank(bank);
		}
		catch (BankException e) {
			 if (e instanceof OverDraftLimitExceededException) {
					System.out.println("Overdraft limit exceeded exception");
					OverDraftLimitExceededException o = (OverDraftLimitExceededException)e;
					System.out.println("Maximum amount to withdraw: " + o.getMaximumAmountToWithdraw());
					System.out.println("Trying to withdraw: " + (o.getMaximumAmountToWithdraw() + o.getAmount()));
					System.out.println("Limit exceeded by: " + o.getAmount());
				}
			else if (e instanceof NotEnoughFundsException) {
				System.out.println("Not enough funds exception");
			}
		}
		BankService.printMaximumAmountToWithdraw(bank);
	}
	
}
